export default ({url, method = 'get', headers = {}, data = {}}) => {
  let options = {
    method,
    headers: {
      'content-type': 'application/json',
      ...headers
    },
    body: method != 'get' ? JSON.stringify(data) : null
  };
  return fetch(url, options).then(res => res.json())
}